--[[
    函数：lua2_safe_set_build_cache_end_v1_1
    功能：设置建立缓存的结束时间，设置之前比较开始时间，相同时才设置
    参数：ARGV[1]:build_start， "2017-08-08 10:02:18",  
    参数：ARGV[2]:build_end， "2017-08-08 10:02:18",  
    返回：返回：
            0:code,0表示成功，其它表示中途退出
--]]

-- ########################################################

-- 分类的前缀
local PREFIX_TYPE = "type_"
-- 标签的前缀
local PREFIX_LABEL = "label_"
-- VIP的key
local KEY_VIP = "vip"
-- 排序的key
local KEY_SORT = "sort"
-- keyword的前缀
local PREFIX_KEYWORD = "kwd_"
-- ID-模版缓存的前缀
local PREFIX_DESIGN = "d_"

-- PPT的ID的前缀
local PREFIX_PPT = "p"
-- key的连接符号
local PREFIX_S = "*"
-- 数组字符串的分割符号
local PREFIX_ARRAY_SPLIT = ","

-- search_db
local SEARCH_DB = "search_db"
-- search_cache_db
local SEARCH_CACHE_DB = "search_cache_db"

-- buildCacheStart
local BUILD_CACHE_START = "buildCacheStart"
-- buildCacheEnd
local BUILD_CACHE_END = "buildCacheEnd"


-- ########################################################
local ret = 0
local build_start = ARGV[1]
local build_end = ARGV[2]


local s = redis.call('get',BUILD_CACHE_START)
if(s and (build_start==s))
then
    redis.call('set',BUILD_CACHE_END, build_end)
else
    ret = 1
end



-- ########################################################
return ret